Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Data
Imports System.Collections
Imports System.Windows.Forms
Imports qLDataLayer
Imports qLDataLayer.BaseProperty
Imports System.Data.SqlClient
Namespace BaseProvider
    Public Class qLProviderThuThu
        'Thừa kế các phương thức cơ bản từ lớp qlBase
        Private oqLBase As New qLBase
        Private oDataSet As New DataSet
        Private oDatatable As New DataTable
        Public Function GetAll_ThuThu(ByVal sConnString As String) As DataTable
            oqLBase.Connection(sConnString)
            oDataSet = oqLBase.GetData("Get_All_ThuThus", "ThuThu")
            Return oDataSet.Tables("ThuThu")
        End Function
        Public Function Insert_ThuThu(ByVal sConnString As String, ByVal oThuThu As qLPropertyThuThu) As Boolean
            Dim SqlParam_ As SqlParameter() = {New SqlParameter("@MaThuThu", SqlDbType.Int), _
                                                New SqlParameter("@TenThuThu", SqlDbType.NVarChar), _
                                                New SqlParameter("@TaiKhoan", SqlDbType.NVarChar), _
                                                New SqlParameter("@MatKhau", SqlDbType.NVarChar), _
                                                New SqlParameter("@DienThoai", SqlDbType.NChar), _
                                                New SqlParameter("@DiaChi", SqlDbType.NVarChar), _
                                                New SqlParameter("@Email", SqlDbType.NChar), _
                                                New SqlParameter("@NgaySinh", SqlDbType.DateTime), _
                                                New SqlParameter("@TrangThai", SqlDbType.Bit), _
                                                New SqlParameter("@MaNhomThuThu", SqlDbType.Int)}
            'Cho phép đặt các giá trị  = NULL
            SqlParam_(0).Direction = ParameterDirection.Output
            SqlParam_(5).IsNullable = True
            SqlParam_(6).IsNullable = True
            SqlParam_(8).IsNullable = True
            'Gán dữ liệu cho các tham số
            SqlParam_(0).Value = oThuThu.MaThuThu
            SqlParam_(1).Value = oThuThu.TenThuThu
            SqlParam_(2).Value = oThuThu.TaiKhoan
            SqlParam_(3).Value = oThuThu.MatKhau
            SqlParam_(4).Value = oThuThu.DienThoai
            SqlParam_(5).Value = oThuThu.DiaChi
            SqlParam_(6).Value = oThuThu.Email
            SqlParam_(7).Value = oThuThu.NgaySinh
            SqlParam_(8).Value = oThuThu.TrangThai
            SqlParam_(9).Value = oThuThu.MaNhomThuThu
            Try
                oqLBase.Connection(sConnString)
                oqLBase.RunStoreProcedures("Insert_ThuThus", "ThuThu", SqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
        Public Function Update_ThuThu(ByVal sConnString As String, ByVal oThuThu As qLPropertyThuThu) As Boolean
            Dim SqlParam_ As SqlParameter() = {New SqlParameter("@MaThuThu", SqlDbType.Int), _
                                                  New SqlParameter("@TenThuThu", SqlDbType.NVarChar), _
                                                  New SqlParameter("@TaiKhoan", SqlDbType.NVarChar), _
                                                  New SqlParameter("@MatKhau", SqlDbType.NVarChar), _
                                                  New SqlParameter("@DienThoai", SqlDbType.NChar), _
                                                  New SqlParameter("@DiaChi", SqlDbType.NVarChar), _
                                                  New SqlParameter("@Email", SqlDbType.NChar), _
                                                  New SqlParameter("@NgaySinh", SqlDbType.DateTime), _
                                                  New SqlParameter("@TrangThai", SqlDbType.Bit), _
                                                  New SqlParameter("@MaNhomThuThu", SqlDbType.Int)}
            'Cho phép đặt các giá trị  = NULL            
            SqlParam_(5).IsNullable = True
            SqlParam_(6).IsNullable = True
            SqlParam_(8).IsNullable = True
            'Gán dữ liệu cho các tham số
            SqlParam_(0).Value = oThuThu.MaThuThu
            SqlParam_(1).Value = oThuThu.TenThuThu
            SqlParam_(2).Value = oThuThu.TaiKhoan
            SqlParam_(3).Value = oThuThu.MatKhau
            SqlParam_(4).Value = oThuThu.DienThoai
            SqlParam_(5).Value = oThuThu.DiaChi
            SqlParam_(6).Value = oThuThu.Email
            SqlParam_(7).Value = oThuThu.NgaySinh
            SqlParam_(8).Value = oThuThu.TrangThai
            SqlParam_(9).Value = oThuThu.MaNhomThuThu
            Try
                oqLBase.Connection(sConnString)
                oqLBase.RunStoreProcedures("Update_ThuThus", "ThuThu", SqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
        Public Function Delete_ThuThu(ByVal sConnString As String, ByVal MaThuThu As String) As Boolean
            Dim SqlParam_ As SqlParameter() = {New SqlParameter("@MaThuThu", SqlDbType.NChar)}
            SqlParam_(0).Value = MaThuThu
            Try
                oqLBase.Connection(sConnString)
                oqLBase.RunStoreProcedures("Delete_ThuThus", "ThuThu", SqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
    End Class
    Public Class qLProviderNhomThuThu
        'Thừa kế các phương thức cơ bản từ lớp qlBase
        Private oqLBase As New qLBase
        Private oDataSet As New DataSet
        Private oDatatable As New DataTable
        Public Function GetAll_NhomThuThu(ByVal sConnString As String) As DataTable
            oqLBase.Connection(sConnString)
            oDataSet = oqLBase.GetData("Get_All_NhomThuThus", "NhomThuThu")
            Return oDataSet.Tables("NhomThuThu")
        End Function
        Public Function Insert_NhomThuThu(ByVal sConnString As String, ByVal oNhomThuThu As qLPropertyNhomThuThu) As Boolean
            Dim SqlParam_ As SqlParameter() = {New SqlParameter("@MaNhomThuThu", SqlDbType.Int), _
                                                New SqlParameter("@TenNhomThuThu", SqlDbType.NVarChar), _
                                                New SqlParameter("@MoTa", SqlDbType.Text)}
            'Cho phép đặt các giá trị  = NULL
            SqlParam_(0).Direction = ParameterDirection.Output
            SqlParam_(2).IsNullable = True
            'Gán dữ liệu cho các tham số
            SqlParam_(0).Value = oNhomThuThu.MaNhomThuThu
            SqlParam_(1).Value = oNhomThuThu.TenNhomThuThu
            SqlParam_(2).Value = oNhomThuThu.MoTa
            Try
                oqLBase.Connection(sConnString)
                oqLBase.RunStoreProcedures("Insert_NhomThuThus", "NhomThuThu", SqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
        Public Function Update_NhomThuThu(ByVal sConnString As String, ByVal oNhomThuThu As qLPropertyNhomThuThu) As Boolean
            Dim SqlParam_ As SqlParameter() = {New SqlParameter("@MaNhomThuThu", SqlDbType.Int), _
                                                New SqlParameter("@TenNhomThuThu", SqlDbType.NVarChar), _
                                                New SqlParameter("@MoTa", SqlDbType.Text)}
            'Cho phép đặt các giá trị  = NULL
            SqlParam_(2).IsNullable = True
            'Gán dữ liệu cho các tham số
            SqlParam_(0).Value = oNhomThuThu.MaNhomThuThu
            SqlParam_(1).Value = oNhomThuThu.TenNhomThuThu
            SqlParam_(2).Value = oNhomThuThu.MoTa
            Try
                oqLBase.Connection(sConnString)
                oqLBase.RunStoreProcedures("Update_NhomThuThus", "NhomThuThu", SqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
        Public Function Delete_NhomThuThu(ByVal sConnString As String, ByVal MaNhomThuThu As String) As Boolean
            Dim SqlParam_ As SqlParameter() = {New SqlParameter("@MaNhomThuThu", SqlDbType.NChar)}
            SqlParam_(0).Value = MaNhomThuThu
            Try
                oqLBase.Connection(sConnString)
                oqLBase.RunStoreProcedures("Delete_NhomThuThus", "NhomThuThu", SqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
    End Class
    Public Class qLProviderSinhVien
        'Thừa kế các phương thức cơ bản từ lớp qlBase
        Private oqlBase As New qLBase
        Private oDataSet As New DataSet
        Private oDataTable As DataTable
        Public Function GetAll_SinhVien(ByVal sConnString As String) As DataTable
            oqlBase.Connection(sConnString)
            oDataSet = oqlBase.GetData("Get_ALL_SinhViens", "SinhVien")
            Return oDataSet.Tables("SinhVien")
        End Function
        Public Function Insert_SinhVien(ByVal sConnString As String, ByVal oSinhVien As qlPropertySinhVien) As Boolean
            Dim SqlParam_ As SqlParameter() = {New SqlParameter("@MaThe", SqlDbType.NChar), _
                                                New SqlParameter("@TenSV", SqlDbType.NVarChar), _
                                                New SqlParameter("@MaSV", SqlDbType.NChar), _
                                                New SqlParameter("@NgaySinh", SqlDbType.DateTime), _
                                                New SqlParameter("@DienThoai", SqlDbType.NChar), _
                                                New SqlParameter("@GioiTinh", SqlDbType.Bit), _
                                                New SqlParameter("@TrangThai", SqlDbType.Bit), _
                                                New SqlParameter("@MoTa", SqlDbType.Text), _
                                                New SqlParameter("@NgayCapThe", SqlDbType.DateTime), _
                                                New SqlParameter("@NgayHetHan", SqlDbType.DateTime)}

            'Cho phép các giá trị Null
            SqlParam_(0).Direction = ParameterDirection.Output
            SqlParam_(3).IsNullable = True
            SqlParam_(4).IsNullable = True
            SqlParam_(5).IsNullable = True
            SqlParam_(8).IsNullable = True
            'Gán dữ liệu cho tham số
            SqlParam_(0).Value = oSinhVien.MaThe
            SqlParam_(1).Value = oSinhVien.TenSV
            SqlParam_(2).Value = oSinhVien.MaSV
            SqlParam_(3).Value = oSinhVien.NgaySinh
            SqlParam_(4).Value = oSinhVien.DienThoai
            SqlParam_(5).Value = oSinhVien.GioiTinh
            SqlParam_(6).Value = oSinhVien.TrangThai
            SqlParam_(7).Value = oSinhVien.MoTa
            SqlParam_(8).Value = oSinhVien.NgayCapThe
            SqlParam_(9).Value = oSinhVien.NgayHetHan
            Try
                oqlBase.Connection(sConnString)
                oqlBase.RunStoreProcedures("Insert_SinhViens", "Sinhvien", SqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
        Public Function Update_SinhVien(ByVal sConnString As String, ByVal oSinhVien As qlPropertySinhVien) As Boolean
            Dim SqlParam_ As SqlParameter() = {New SqlParameter("@MaThe", SqlDbType.NChar), _
                                                New SqlParameter("@TenSV", SqlDbType.NVarChar), _
                                                New SqlParameter("@MaSV", SqlDbType.NChar), _
                                                New SqlParameter("@NgaySinh", SqlDbType.DateTime), _
                                                New SqlParameter("@DienThoai", SqlDbType.NChar), _
                                                New SqlParameter("@GioiTinh", SqlDbType.Bit), _
                                                New SqlParameter("@TrangThai", SqlDbType.Bit), _
                                                New SqlParameter("@MoTa", SqlDbType.Text), _
                                                New SqlParameter("@NgayCapThe", SqlDbType.DateTime), _
                                                New SqlParameter("@NgayHetHan", SqlDbType.DateTime)}

            'Cho phép các giá trị Null
            SqlParam_(3).IsNullable = True
            SqlParam_(4).IsNullable = True
            SqlParam_(5).IsNullable = True
            SqlParam_(8).IsNullable = True
            'Gán dữ liệu cho tham số
            SqlParam_(0).Value = oSinhVien.MaThe
            SqlParam_(1).Value = oSinhVien.TenSV
            SqlParam_(2).Value = oSinhVien.MaSV
            SqlParam_(3).Value = oSinhVien.NgaySinh
            SqlParam_(4).Value = oSinhVien.DienThoai
            SqlParam_(5).Value = oSinhVien.GioiTinh
            SqlParam_(6).Value = oSinhVien.TrangThai
            SqlParam_(7).Value = oSinhVien.MoTa
            SqlParam_(8).Value = oSinhVien.NgayCapThe
            SqlParam_(9).Value = oSinhVien.NgayHetHan
            Try
                oqlBase.Connection(sConnString)
                oqlBase.RunStoreProcedures("Update_Sinviens", "SinhVien", SqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
        Public Function Delete_SinhVien(ByVal sConnString As String, ByVal MaThe As String) As Boolean
            Dim SqlParam_ As SqlParameter() = {New SqlParameter("@MaThe", SqlDbType.NChar)}
            SqlParam_(0).Value = MaThe
            Try
                oqlBase.Connection(sConnString)
                oqlBase.RunStoreProcedures("Delete_SinhViens", "SinhVien", SqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
    End Class
    Public Class qlProviderKhoa
        'Thừa kế các phương thức cơ bản từ lớp qlBase
        Private oqlBase As New qLBase
        Private oDataSet As New DataSet
        Private oDataTable As New DataTable
        Public Function GetAll_Khoa(ByVal sConnString As String) As DataTable
            oqlBase.Connection(sConnString)
            oDataSet = oqlBase.GetData("Get_ALL_Khoas", "Khoa")
            Return oDataSet.Tables("Khoa")
        End Function
        Public Function Insert_Khoa(ByVal sConnString As String, ByVal oKhoa As qlPropertyKhoa) As Boolean
            Dim SqlParam_ As SqlParameter() = {New SqlParameter("@MaKhoa", SqlDbType.NChar), _
                                                 New SqlParameter("@TenKhoa", SqlDbType.NVarChar), _
                                                 New SqlParameter("@DienThoai", SqlDbType.NChar), _
                                                 New SqlParameter("@MoTa", SqlDbType.Text)}
            'Cho phép null
            SqlParam_(0).Direction = ParameterDirection.Output
            SqlParam_(2).IsNullable = True
            SqlParam_(3).IsNullable = True
            'gán dữ liệu cho tham số
            SqlParam_(0).Value = oKhoa.MaKhoa
            SqlParam_(1).Value = oKhoa.TenKhoa
            SqlParam_(2).Value = oKhoa.DienThoai
            SqlParam_(3).Value = oKhoa.Mota
            Try
                oqlBase.Connection(sConnString)
                oqlBase.RunStoreProcedures("Insert_Khoas", "Khoa", SqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
        Public Function Update_Khoa(ByVal sConnString As String, ByVal oKhoa As qlPropertyKhoa) As Boolean
            Dim SqlParam_ As SqlParameter() = {New SqlParameter("@MaKhoa", SqlDbType.NChar), _
                                                            New SqlParameter("@TenKhoa", SqlDbType.NVarChar), _
                                                            New SqlParameter("@DienThoai", SqlDbType.NChar), _
                                                            New SqlParameter("@MoTa", SqlDbType.Text)}
            'Cho phép null
            SqlParam_(2).IsNullable = oKhoa.DienThoai
            SqlParam_(3).IsNullable = oKhoa.Mota
            'gán dữ liệu cho tham số
            SqlParam_(0).Value = oKhoa.MaKhoa
            SqlParam_(1).Value = oKhoa.TenKhoa
            SqlParam_(2).Value = oKhoa.DienThoai
            SqlParam_(3).Value = oKhoa.Mota
            Try
                oqlBase.Connection(sConnString)
                oqlBase.RunStoreProcedures("Update_Khoas", "Khoa", SqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
        Public Function Delete_Khoa(ByVal sConnString As String, ByVal MaKhoa As String) As Boolean
            Dim sqlParam_ As SqlParameter() = {New SqlParameter("@MaKhoa", SqlDbType.NChar)}
            sqlParam_(0).Value = MaKhoa
            Try
                oqlBase.Connection(sConnString)
                oqlBase.RunStoreProcedures("Delete_Khoas", "Khoa", sqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
        End Function
    End Class
    Public Class qlProviderLop
        'Thừa kế các phương thức cơ bản từ lớp qlBase
        Private oqlBase As New qLBase
        Private oDataSet As New DataSet
        Private oDataTable As New DataTable
        Public Function GetAll_Lop(ByVal sConnString As String) As DataTable
            oqlBase.Connection(sConnString)
            oDataSet = oqlBase.GetData("Get_All_Lops", "Lop")
            Return oDataSet.Tables("Lop")
        End Function
        Public Function Insert_Lop(ByVal sConnString As String, ByVal oLop As qlPropertyLop) As Boolean
            Dim sqlParam_ As SqlParameter() = {New SqlParameter("@MaLop", SqlDbType.NChar), _
                                                New SqlParameter("@TenLop", SqlDbType.NVarChar), _
                                                New SqlParameter("@LopTruong", SqlDbType.NVarChar), _
                                                New SqlParameter("@DienThoai", SqlDbType.NChar), _
                                                New SqlParameter("@MoTa", SqlDbType.Text), _
                                                New SqlParameter("@MaKhoa", SqlDbType.NChar), _
                                                New SqlParameter("@KhoaHoc", SqlDbType.Int)}
            'Cho phép Null
            sqlParam_(0).Direction = ParameterDirection.Output
            sqlParam_(4).IsNullable = True
            'Gán giá trị cho tham số
            sqlParam_(0).Value = oLop.MaLop
            sqlParam_(1).Value = oLop.TenLop
            sqlParam_(2).Value = oLop.LopTruong
            sqlParam_(3).Value = oLop.DienThoai
            sqlParam_(4).Value = oLop.MoTa
            sqlParam_(5).Value = oLop.MaKhoa
            sqlParam_(6).Value = oLop.KhoaHoc
            Try
                oqlBase.Connection(sConnString)
                oqlBase.RunStoreProcedures("Insert_Lops", "Lop", sqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
        Public Function Update_Lop(ByVal sConnString As String, ByVal oLop As qlPropertyLop) As Boolean
            Dim sqlParam_ As SqlParameter() = {New SqlParameter("@MaLop", SqlDbType.NChar), _
                                                           New SqlParameter("@TenLop", SqlDbType.NVarChar), _
                                                           New SqlParameter("@LopTruong", SqlDbType.NVarChar), _
                                                           New SqlParameter("@DienThoai", SqlDbType.NChar), _
                                                           New SqlParameter("@MoTa", SqlDbType.Text), _
                                                           New SqlParameter("@MaKhoa", SqlDbType.NChar), _
                                                           New SqlParameter("@KhoaHoc", SqlDbType.Int)}
            'Cho phép Null
            sqlParam_(4).IsNullable = True
            'Gán giá trị cho tham số
            sqlParam_(0).Value = oLop.MaLop
            sqlParam_(1).Value = oLop.TenLop
            sqlParam_(2).Value = oLop.LopTruong
            sqlParam_(3).Value = oLop.DienThoai
            sqlParam_(4).Value = oLop.MoTa
            sqlParam_(5).Value = oLop.MaKhoa
            sqlParam_(6).Value = oLop.KhoaHoc
            Try
                oqlBase.Connection(sConnString)
                oqlBase.RunStoreProcedures("Update_Lops", "Lop", sqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
        Public Function Delete_Lop(ByVal sConnString As String, ByVal MaLop As String) As Boolean
            Dim sqlparam_ As SqlParameter() = {New SqlParameter("@Malop", SqlDbType.NChar)}
            sqlparam_(0).Value = MaLop
            Try
                oqlBase.Connection(sConnString)
                oqlBase.RunStoreProcedures("Delete_Lops", "Lop", sqlparam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
    End Class
    Public Class qlProviderChuyenMucSach
        'Thừa kế các phương thức cơ bản từ lớp qlBase
        Private oqLBase As New qLBase
        Private oDataSet As New DataSet
        Private oDatatable As New DataTable
        Public Function GetAll_ChuyenMucSach(ByVal sConnString As String) As DataTable
            oqLBase.Connection(sConnString)
            oqLBase.GetData("Get_ALL_ChuyenMucSachs", "ChuyenMucSach")
            Return oDataSet.Tables("ChuyenMucSach")
        End Function
        Public Function Insert_ChuyenMucSach(ByVal sConnString As String, ByVal oChuyenMucSach As qlPropertyChuyenMucSach) As Boolean
            Dim sqlParam_ As SqlParameter() = {New SqlParameter("@MaChuyenMucSach", SqlDbType.NChar), _
                                                New SqlParameter("@TenChuyenMucSach", SqlDbType.NVarChar), _
                                                New SqlParameter("@MoTa", SqlDbType.Text)}
            'Cho phép Null
            sqlParam_(0).Direction = ParameterDirection.Output
            sqlParam_(2).IsNullable = True
            'Gán giá trị cho tham số
            sqlParam_(0).Value = oChuyenMucSach.MaChuyenMucSach
            sqlParam_(1).Value = oChuyenMucSach.TenChuyenMucSach
            sqlParam_(2).Value = oChuyenMucSach.MoTa

            Try
                oqLBase.Connection(sConnString)
                oqLBase.RunStoreProcedures("Insert_ChuyenMucSachs", "ChuyenMucSach", sqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
        Public Function Update_ChuyenMucSach(ByVal sConnString As String, ByVal oChuyenMucSach As qlPropertyChuyenMucSach) As Boolean
            Dim sqlParam_ As SqlParameter() = {New SqlParameter("@MaChuyenMucSach", SqlDbType.NChar), _
                                                New SqlParameter("@TenChuyenMucSach", SqlDbType.NVarChar), _
                                                New SqlParameter("@MoTa", SqlDbType.Text)}
            'Cho phép Null
            sqlParam_(2).IsNullable = True
            'Gán giá trị cho tham số
            sqlParam_(0).Value = oChuyenMucSach.MaChuyenMucSach
            sqlParam_(1).Value = oChuyenMucSach.TenChuyenMucSach
            sqlParam_(2).Value = oChuyenMucSach.MoTa

            Try
                oqLBase.Connection(sConnString)
                oqLBase.RunStoreProcedures("Update_ChuyenMucSachs", "ChuyenMucSach", sqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
        Public Function Delete_ChuyenMucSach(ByVal sConnString As String, ByVal MaChuyenMucSach As String) As Boolean
            Dim sqlParam_ As SqlParameter() = {New SqlParameter("@MaChuyenMcuSach", SqlDbType.NChar)}
            sqlParam_(0).Value = MaChuyenMucSach
            Try
                oqLBase.Connection(sConnString)
                oqLBase.RunStoreProcedures("Delete_ChuyenMucSachs", "ChuyenMucSach", sqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
    End Class
    Public Class qlProviderSach
        'Thừa kế các phương thức cơ bản từ lớp qlBase
        Private oqlBase As qLBase
        Private oDataSet As DataSet
        Private oDatatable As DataTable
        Public Function GetAll_Sach(ByVal sConnString As String) As DataTable
            oqlBase.Connection(sConnString)
            oqlBase.GetData("Get_ALL_Sachs", "Sach")
            Return oDataSet.Tables("Sach")
        End Function
        Public Function Insert_Sach(ByVal sConnString As String, ByVal oSach As qlPropertySach) As Boolean
            Dim sqlParam_ As SqlParameter() = {New SqlParameter("@MaSach", SqlDbType.Int), _
                                                New SqlParameter("@MaVach", SqlDbType.Int), _
                                                New SqlParameter("@TenSach", SqlDbType.NVarChar), _
                                                New SqlParameter("@MaChuyenMucSach", SqlDbType.Int), _
                                                New SqlParameter("@MaViTri", SqlDbType.Int), _
                                                New SqlParameter("@MaNgonNgu", SqlDbType.Int), _
                                                New SqlParameter("@MaNXB", SqlDbType.Int), _
                                                New SqlParameter("@MaTacGia", SqlDbType.Int), _
                                                New SqlParameter("@SoTrang", SqlDbType.Int), _
                                                New SqlParameter("@NamXuatBan", SqlDbType.Int), _
                                                New SqlParameter("@SoLuong", SqlDbType.Int), _
                                                New SqlParameter("@DonGia", SqlDbType.Money), _
                                                New SqlParameter("@KichThuoc", SqlDbType.NChar), _
                                                New SqlParameter("@NgayNhap", SqlDbType.DateTime), _
                                                New SqlParameter("@SoLuongCo", SqlDbType.Int), _
                                                New SqlParameter("@MoTa", SqlDbType.Text)}
            'Cho phép Null
            sqlParam_(0).Direction = ParameterDirection.Output
            sqlParam_(15).IsNullable = True
            'Gán dữ liệu cho tham số
            sqlParam_(0).Value = oSach.MaSach
            sqlParam_(1).Value = oSach.MaVach
            sqlParam_(2).Value = oSach.TenSach
            sqlParam_(3).Value = oSach.MaChuyenMucSach
            sqlParam_(4).Value = oSach.MaViTri
            sqlParam_(5).Value = oSach.MaNgonNgu
            sqlParam_(6).Value = oSach.MaNXB
            sqlParam_(7).Value = oSach.MaTacGia
            sqlParam_(8).Value = oSach.SoTrang
            sqlParam_(9).Value = oSach.NamXuatBan
            sqlParam_(10).Value = oSach.SoLuong
            sqlParam_(11).Value = oSach.DonGia
            sqlParam_(12).Value = oSach.KichThuoc
            sqlParam_(13).Value = oSach.NgayNhap
            sqlParam_(14).Value = oSach.SoLuongCo
            sqlParam_(15).Value = oSach.MoTa
            Try
                oqlBase.Connection(sConnString)
                oqlBase.RunStoreProcedures("Insert_Sachs", "Sach", sqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
        Public Function Update_Sach(ByVal sConnString As String, ByVal oSach As qlPropertySach) As Boolean
            Dim sqlParam_ As SqlParameter() = {New SqlParameter("@MaSach", SqlDbType.Int), _
                                                New SqlParameter("@MaVach", SqlDbType.Int), _
                                                New SqlParameter("@TenSach", SqlDbType.NVarChar), _
                                                New SqlParameter("@MaChuyenMucSach", SqlDbType.Int), _
                                                New SqlParameter("@MaViTri", SqlDbType.Int), _
                                                New SqlParameter("@MaNgonNgu", SqlDbType.Int), _
                                                New SqlParameter("@MaNXB", SqlDbType.Int), _
                                                New SqlParameter("@MaTacGia", SqlDbType.Int), _
                                                New SqlParameter("@SoTrang", SqlDbType.Int), _
                                                New SqlParameter("@NamXuatBan", SqlDbType.Int), _
                                                New SqlParameter("@SoLuong", SqlDbType.Int), _
                                                New SqlParameter("@DonGia", SqlDbType.Money), _
                                                New SqlParameter("@KichThuoc", SqlDbType.NChar), _
                                                New SqlParameter("@NgayNhap", SqlDbType.DateTime), _
                                                New SqlParameter("@SoLuongCo", SqlDbType.Int), _
                                                New SqlParameter("@MoTa", SqlDbType.Text)}
            'Cho phép Null
            sqlParam_(15).IsNullable = True
            'Gán dữ liệu cho tham số
            sqlParam_(0).Value = oSach.MaSach
            sqlParam_(1).Value = oSach.MaVach
            sqlParam_(2).Value = oSach.TenSach
            sqlParam_(3).Value = oSach.MaChuyenMucSach
            sqlParam_(4).Value = oSach.MaViTri
            sqlParam_(5).Value = oSach.MaNgonNgu
            sqlParam_(6).Value = oSach.MaNXB
            sqlParam_(7).Value = oSach.MaTacGia
            sqlParam_(8).Value = oSach.SoTrang
            sqlParam_(9).Value = oSach.NamXuatBan
            sqlParam_(10).Value = oSach.SoLuong
            sqlParam_(11).Value = oSach.DonGia
            sqlParam_(12).Value = oSach.KichThuoc
            sqlParam_(13).Value = oSach.NgayNhap
            sqlParam_(14).Value = oSach.SoLuongCo
            sqlParam_(15).Value = oSach.MoTa
            Try
                oqlBase.Connection(sConnString)
                oqlBase.RunStoreProcedures("Update_Sachs", "Sach", sqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
        Public Function Delete_Sach(ByVal sConnString As String, ByVal MaSach As String) As Boolean
            Dim sqlparam_ As SqlParameter() = {New SqlParameter("@MaSach", SqlDbType.NChar)}
            sqlparam_(0).Value = MaSach
            Try
                oqlBase.Connection(sConnString)
                oqlBase.RunStoreProcedures("Delete_Sachs", "Sach", sqlparam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
    End Class
    Public Class qlProviderNgonNgu
        Private oqlBase As qLBase
        Private oDataSet As DataSet
        Private oDatatable As DataTable
        Public Function GetAll_NgonNgu(ByVal sConnString As String) As DataTable
            oqlBase.Connection(sConnString)
            oqlBase.GetData("Get_ALl_NgonNgus", "NgonNgu")
            Return oDataSet.Tables("NgonNgu")
        End Function
        Public Function Insert_NgonNgu(ByVal sConnString As String, ByVal oNgonNgu As qlPropertyNgonngu) As Boolean
            Dim sqlParam_ As SqlParameter() = {New SqlParameter("@MaNgonNgu", SqlDbType.Int), _
                                                New SqlParameter("@TenNgonNgu", SqlDbType.NVarChar)}

            'Cho Phep Null
            sqlParam_(0).Direction = ParameterDirection.Input
            'Gan du lieu cho tham so
            sqlParam_(0).Value = oNgonNgu.MaNgonNgu
            sqlParam_(1).Value = oNgonNgu.TenNgonNGu
            Try
                oqlBase.Connection(sConnString)
                oqlBase.RunStoreProcedures("Insert_NgonNgus", "NgonNgu", sqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
        Public Function Update_NgonNgu(ByVal sConnString As String, ByVal oNgonNgu As qlPropertyNgonngu) As Boolean
            Dim sqlParam_ As SqlParameter() = {New SqlParameter("@MaNgonNgu", SqlDbType.Int), _
                                                New SqlParameter("TenNgonNgu", SqlDbType.NVarChar)}

            'Gan Du Lieu Cho Tham So
            sqlParam_(0).Value = oNgonNgu.MaNgonNgu
            sqlParam_(1).Value = oNgonNgu.TenNgonNgu
            Try
                oqlBase.Connection(sConnString)
                oqlBase.RunStoreProcedures("Update_NgonNgus", "NgonNgu", sqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông Báo Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
        Public Function Delete_NgonNgu(ByVal sConnstring As String, ByVal MaNgonNgu As Integer) As Boolean
            Dim sqlParam_ As SqlParameter() = {New SqlParameter("@MaNgonNgu", SqlDbType.Int)}
            sqlParam_(0).Value = MaNgonNgu
            Try
                oqlBase.Connection(sConnstring)
                oqlBase.RunStoreProcedures("Delete_NgonNgus", "NgonNgu", sqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
    End Class
    Public Class qlProviderNXB
        Private oqlBase As New qLBase
        Private oDataSet As New DataSet
        Private oDataTable As DataTable
        Public Function GetALL_NXB(ByVal sConnString As String) As DataTable
            oqlBase.Connection(sConnString)
            oDataSet = oqlBase.GetData("Get_ALL_NXBs", "NXB")
            Return oDataSet.Tables("NXB")
        End Function
        Public Function Insert_NXB(ByVal sConnString As String, ByVal oNXB As qlPropertyNXB) As Boolean
            Dim sqlParam_ As SqlParameter() = {New SqlParameter("@MaNXB", SqlDbType.Int), _
                                                New SqlParameter("@TenNXB", SqlDbType.NVarChar)}
            sqlParam_(0).Direction = ParameterDirection.Output
            'Gán dữ liệu vào tham số
            sqlParam_(0).Value = oNXB.MaNXB
            sqlParam_(1).Value = oNXB.TenNXB
            Try
                oqlBase.Connection(sConnString)
                oqlBase.RunStoreProcedures("Insert_NXBs", "NXB", sqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function


        Public Function Update_NXB(ByVal sConnString As String, ByVal oNXB As qlPropertyNXB) As Boolean
            Dim sqlParam_ As SqlParameter() = {New SqlParameter("@MaNXB", SqlDbType.Int), _
                                                New SqlParameter("@TenNXB", SqlDbType.NVarChar)}
            sqlParam_(0).Value = oNXB.MaNXB
            sqlParam_(1).Value = oNXB.TenNXB
            Try
                oqlBase.Connection(sConnString)
                oqlBase.RunStoreProcedures("Update_NXBs", "NXB", sqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
        Public Function Delete_NXB(ByVal sConnString As String, ByVal MaNXB As Integer) As Boolean
            Dim sqlParam_ As SqlParameter() = {New SqlParameter("@MaNXB", SqlDbType.Int)}
            sqlParam_(0).Value = MaNXB
            Try
                oqlBase.Connection(sConnString)
                oqlBase.RunStoreProcedures("Delete_NXBs", "NXB", sqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
    End Class
    Public Class qlProviderViTri
        Private oqlBase As New qLBase
        Private oDataSet As New DataSet
        Private oDataTable As DataTable
        Public Function GetALL_ViTri(ByVal sConnString As String) As DataTable
            oqlBase.Connection(sConnString)
            oDataSet = oqlBase.GetData("Get_ALL_ViTris", "ViTri")
            Return oDataSet.Tables("ViTri")
        End Function
        Public Function Insert_ViTri(ByVal sConnString As String, ByVal oViTri As qlPropertyViTri) As Boolean
            Dim sqlParam_ As SqlParameter() = {New SqlParameter("@MaViTri", SqlDbType.Int), _
                                                New SqlParameter("@TenViTri", SqlDbType.NVarChar), _
                                                New SqlParameter("@MoTa", SqlDbType.Text)}
            sqlParam_(0).Direction = ParameterDirection.Output
            sqlParam_(2).IsNullable = True

            sqlParam_(0).Value = oViTri.MaViTri
            sqlParam_(1).Value = oViTri.TenViTri
            sqlParam_(2).Value = oViTri.MoTa
            Try
                oqlBase.Connection(sConnString)
                oqlBase.RunStoreProcedures("Insert_ViTris", "ViTri", sqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
        Public Function Update_ViTri(ByVal sConnString As String, ByVal oViTri As qlPropertyViTri) As Boolean
            Dim sqlParam_ As SqlParameter() = {New SqlParameter("@MaViTri", SqlDbType.Int), _
                                                New SqlParameter("@TenViTri", SqlDbType.NVarChar), _
                                                New SqlParameter("@MoTa", SqlDbType.Text)}
            sqlParam_(2).IsNullable = True
            sqlParam_(0).Value = oViTri.MaViTri
            sqlParam_(1).Value = oViTri.TenViTri
            sqlParam_(2).Value = oViTri.MoTa
            Try
                oqlBase.Connection(sConnString)
                oqlBase.RunStoreProcedures("Update_ViTris", "ViTri", sqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
        Public Function Delete_ViTri(ByVal sConnString As String, ByVal MaViTri As Integer) As Boolean
            Dim sqlParam_ As SqlParameter() = {New SqlParameter("@MaViTri", SqlDbType.Int)}
            sqlParam_(0).Value = MaViTri
            Try
                oqlBase.Connection(sConnString)
                oqlBase.RunStoreProcedures("Delete_ViTris", "ViTri", sqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
    End Class
    Public Class qlPrividerTacGia
        Private oqLBase As New qLBase
        Private oDataSet As New DataSet
        Private oDataTable As DataTable
        Public Function GetALL_TacGia(ByVal sConnString As String) As DataTable
            oqLBase.Connection(sConnString)
            oDataSet = oqLBase.GetData("Get_ALL_TacGias", "TacGia")
            Return oDataSet.Tables("TacGia")
        End Function
        Public Function Insert_TacGia(ByVal sConnString As String, ByVal oTacGia As qlPropertyTacGia) As Boolean
            Dim sqlParam_ As SqlParameter() = {New SqlParameter("@MaTacGia", SqlDbType.Int), _
                                                New SqlParameter("@TenTacGia", SqlDbType.NVarChar), _
                                                New SqlParameter("@MoTa", SqlDbType.Text)}
            sqlParam_(0).Direction = ParameterDirection.Output
            sqlParam_(2).IsNullable = True
            sqlParam_(0).Value = oTacGia.MaTacGia
            sqlParam_(1).Value = oTacGia.TenTacGia
            sqlParam_(2).Value = oTacGia.MoTa
            Try
                oqLBase.Connection(sConnString)
                oqLBase.RunStoreProcedures("Insert_TacGias", "TacGia", sqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
        Public Function Update_TacGia(ByVal sConnstring As String, ByVal oTacGia As qlPropertyTacGia) As Boolean
            Dim sqlParam_ As SqlParameter() = {New SqlParameter("@MaTacGia", SqlDbType.Int), _
                                                New SqlParameter("@TenTacGia", SqlDbType.NVarChar), _
                                                New SqlParameter("@MoTa", SqlDbType.Text)}
            sqlParam_(2).IsNullable = True
            sqlParam_(0).Value = oTacGia.MaTacGia
            sqlParam_(1).Value = oTacGia.TenTacGia
            sqlParam_(2).Value = oTacGia.MoTa
            Try
                oqLBase.Connection(sConnstring)
                oqLBase.RunStoreProcedures("Update_TacGias", "TacGia", sqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
        Public Function Delete_TacGia(ByVal sConnString As String, ByVal MaTacGia As Integer) As Boolean
            Dim sqlParam_ As SqlParameter() = {New SqlParameter("@MaTacGia", SqlDbType.Int)}
            sqlParam_(0).Value = MaTacGia
            Try
                oqLBase.Connection(sConnString)
                oqLBase.RunStoreProcedures("Delete_TacGias", "TacGia", sqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
    End Class
    Public Class qlPrividerPhieuMuon
        Private oqLBase As New qLBase
        Private oDataSet As New DataSet
        Private oDataTable As DataTable
        Public Function GetALL_PhieuMuon(ByVal sConnString As String) As DataTable
            oqLBase.Connection(sConnString)
            oDataSet = oqLBase.GetData("Get_ALL_PhieuMuons", "PhieuMuon")
            Return oDataSet.Tables("PhieuMuon")
        End Function
        Public Function Insert_PhieuMuon(ByVal sConnString As String, ByVal oPhieuMuon As qlPropertyPhieuMuon) As Boolean
            Dim sqlParam_ As SqlParameter() = {New SqlParameter("@MaPhieu", SqlDbType.Int), _
                                                New SqlParameter("@MaThe", SqlDbType.NChar), _
                                                New SqlParameter("@NgayMuon", SqlDbType.DateTime), _
                                                New SqlParameter("@NgayTra", SqlDbType.DateTime), _
                                                New SqlParameter("@TinhTrang", SqlDbType.Bit), _
                                                New SqlParameter("@MoTa", SqlDbType.Text)}
            sqlParam_(0).Direction = ParameterDirection.Output
            sqlParam_(5).IsNullable = True
            sqlParam_(0).Value = oPhieuMuon.MaPhieu
            sqlParam_(1).Value = oPhieuMuon.MaThe
            sqlParam_(2).Value = oPhieuMuon.NgayMuon
            sqlParam_(3).Value = oPhieuMuon.NgayTra
            sqlParam_(4).Value = oPhieuMuon.TinhTrang
            sqlParam_(5).Value = oPhieuMuon.MoTa
            Try
                oqLBase.Connection(sConnString)
                oqLBase.RunStoreProcedures("Insert_PhieuMuons", "PhieuMuon", sqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
        Public Function Update_PhieuMuon(ByVal sConnstring As String, ByVal oPhieuMuon As qlPropertyPhieuMuon) As Boolean
            Dim sqlParam_ As SqlParameter() = {New SqlParameter("@MaPhieu", SqlDbType.Int), _
                                                     New SqlParameter("@MaThe", SqlDbType.NChar), _
                                                     New SqlParameter("@NgayMuon", SqlDbType.DateTime), _
                                                     New SqlParameter("@NgayTra", SqlDbType.DateTime), _
                                                     New SqlParameter("@TinhTrang", SqlDbType.Bit), _
                                                     New SqlParameter("@MoTa", SqlDbType.Text)}
            sqlParam_(0).Direction = ParameterDirection.Output
            sqlParam_(5).IsNullable = True
            sqlParam_(0).Value = oPhieuMuon.MaPhieu
            sqlParam_(1).Value = oPhieuMuon.MaThe
            sqlParam_(2).Value = oPhieuMuon.NgayMuon
            sqlParam_(3).Value = oPhieuMuon.NgayTra
            sqlParam_(4).Value = oPhieuMuon.TinhTrang
            sqlParam_(5).Value = oPhieuMuon.MoTa
            Try
                oqLBase.Connection(sConnstring)
                oqLBase.RunStoreProcedures("Update_PhieuMuons", "PhieuMuon", sqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
        Public Function Delete_TacGia(ByVal sConnString As String, ByVal MaTacGia As Integer) As Boolean
            Dim sqlParam_ As SqlParameter() = {New SqlParameter("@MaTacGia", SqlDbType.Int)}
            sqlParam_(0).Value = MaTacGia
            Try
                oqLBase.Connection(sConnString)
                oqLBase.RunStoreProcedures("Delete_TacGias", "TacGia", sqlParam_)
                Return True
            Catch ex As Exception
                MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return False
            End Try
        End Function
    End Class
End Namespace
